-- 自定义code actions
local null_ls = require("null-ls")

local isTest = function(content)
  -- vim.notify("parse struct...")
  return true
end

local my_actions = {
  method = null_ls.methods.CODE_ACTION,
  filetypes = { "go" },
  generator = {
    fn = function(context)
      if isTest(context.content) then
        vim.notify("yueking")
        return {
          {
            title = "introduce local variable",
            action = function()
              -- Go to start of line
              -- Go to before next word
              -- Add the last inserted text
              -- Add " = "
              -- Add the last deleted text
              -- Add a <Cr> to separate the new line from the old line (and vim preserves the indentation)
              -- vim.api.nvim_command("GoTagAdd json")
            end,
          },
          {
            title = "Handle error",
            action = function()
              -- vim.api.nvim_command("GoTagAdd json")
            end,
          },
        }
      end
    end,
  },
}

null_ls.register(my_actions)
